Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor enhancement : Use Arrow Link for the Force Dependency graph #373

Merged
merged 6 commits into from
Jul 15, 2019
Merged

Minor enhancement : Use Arrow Link for the Force Dependency graph #373

merged 6 commits into from
Jul 15, 2019

Conversation

Etienne-Carriere
Copy link
Contributor

Replace simple link by Arrow link in the Force Dependency graph so that the graph is more
understandable

Signed-off-by: Etienne Carriere etienne.a.carriere@socgen.com

Which problem is this PR solving?

Currently, in the Force Directed Graph, we don't know the direction of the dependency between 2 services.

Short description of the changes

Replacing "not arrow link" by "Arrow link" in the graph

@codecov
Copy link

codecov bot commented Apr 25, 2019

Codecov Report

Merging #373 into master will decrease coverage by 0.14%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   89.07%   88.93%   -0.15%     
==========================================
  Files         162      163       +1     
  Lines        3663     3670       +7     
  Branches      833      834       +1     
==========================================
+ Hits         3263     3264       +1     
- Misses        364      369       +5     
- Partials       36       37       +1
Impacted Files Coverage Δ
packages/jaeger-ui/src/propTypes/dependencies.js 100% <ø> (ø) ⬆️
packages/jaeger-ui/src/selectors/dependencies.js 100% <ø> (ø) ⬆️
...components/DependencyGraph/DependencyForceGraph.js 85% <100%> (+0.78%) ⬆️
.../components/DependencyGraph/ForceGraphArrowLink.js 33.33% <33.33%> (ø)
...eViewer/TimelineHeaderRow/TimelineViewingLayer.tsx 88.13% <0%> (-3.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f682682...0a19ebb. Read the comment docs.

Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Can you add a couple of screenshots?

@Etienne-Carriere
Copy link
Contributor Author

Etienne-Carriere commented May 2, 2019

@tiffon , here is the example for a simple dependency graph :
{"dependencies": [ {"parent":"service1","child":"service2","callCount":1000}, {"parent":"service2","child":"service3","callCount":100}, {"parent":"service1","child":"service3","callCount":100}, {"parent":"service3","child":"service4","callCount":10}, {"parent":"service4","child":"service3","callCount":101} ], "timestamp":"2019-05-02T00:00:00Z" }

Currently :

CURRENTLY_Not_Directed_Graph_with_label

Proposal :
PROPOSAL_Directed_Graph_with_label

Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the arrows get covered by nodes with a large radius:

Screen Shot 2019-05-02 at 5 41 01 PM

We have some nodes that cover the arrow completely.

Can you see if it's possible to account for this? I think there is a targetRadius prop that might do the trick?

@Etienne-Carriere
Copy link
Contributor Author

@tiffon, thank you for the remark.

I made some tests and the targetRadius is more for an homothetic ratio which is not great for "big nodes" so I try a translation of the marker on the link and I have something interesting .

Unfortunately, I have to patch the ForceGraphArrowLink (https://github.com/uber/react-vis-force/blob/master/src/components/ForceGraphArrowLink.js) . 2 possible solutions :

  • Patch the react-vis-force lib but seems to be not maintained (last patch in 2017)
  • Have a monkey-patch (new composant JaegerForceGraphArrowLink) in Jaeger-ui

What do you prefer ?

@tiffon
Copy link
Member

tiffon commented May 3, 2019

I see what you mean. It's very unfortunate, but yeah, we're probably not going to get much traction on updating the library, and I would generally prefer not to have a fork of it...

@yurishkuro, can you weigh in on supporting arrows in the links? The main issue is that in cases where the nodes have a large radius, the node covers the arrows.

Screen Shot 2019-05-03 at 12 47 53 PM

Note: The purple arrows are my annotations.

In the image above, the opacity is reduced. This allows the arrows, which are behind the green nodes, to be visible. The dark, concentric effects in the large nodes are the visual effect of the arrows that are behind the nodes.

What do you think?

@Etienne-Carriere
Copy link
Contributor Author

@tiffon
Copy link
Member

tiffon commented May 14, 2019

@Etienne-Carriere Using a local arrow link works great!

In the layout of the edges, I noticed that sometimes the edges are off-center and / or the arrow is hidden behind the target node.

Screen Shot 2019-05-14 at 3 49 12 PM

The following changes seem to address these issues:

diff --git a/packages/jaeger-ui/src/components/DependencyGraph/DependencyForceGraph.js b/packages/jaeger-ui/src/components/DependencyGraph/DependencyForceGraph.js
index e27ab40..a7e856b 100644
--- a/packages/jaeger-ui/src/components/DependencyGraph/DependencyForceGraph.js
+++ b/packages/jaeger-ui/src/components/DependencyGraph/DependencyForceGraph.js
@@ -60,6 +60,7 @@ export default class DependencyForceGraph extends Component {
   render() {
     const { nodes, links } = this.props;
     const { width, height } = this.state;
+    const nodesMap = new Map(nodes.map(node => [node.id, node]));
 
     return (
       <div
@@ -103,7 +104,12 @@ export default class DependencyForceGraph extends Component {
             />
           ))}
           {links.map(({ opacity, ...link }) => (
-            <JaegerForceGraphArrowLink key={`${link.source}=>${link.target}`} opacity={opacity} link={link} />
+            <JaegerForceGraphArrowLink
+              key={`${link.source}=>${link.target}`}
+              opacity={opacity}
+              link={link}
+              targetRadius={nodesMap.get(link.target).radius}
+            />
           ))}
         </InteractiveForceGraph>
       </div>
diff --git a/packages/jaeger-ui/src/components/DependencyGraph/JaegerForceGraphArrowLink.js b/packages/jaeger-ui/src/components/DependencyGraph/JaegerForceGraphArrowLink.js
index 3160f56..aaf9516 100644
--- a/packages/jaeger-ui/src/components/DependencyGraph/JaegerForceGraphArrowLink.js
+++ b/packages/jaeger-ui/src/components/DependencyGraph/JaegerForceGraphArrowLink.js
@@ -28,7 +28,7 @@ import { ForceGraphLink} from 'react-vis-force';
 }
 
 
-export default class JaegerForceGraphArrowLink extends PureComponent { 
+export default class JaegerForceGraphArrowLink extends PureComponent {
   static get propTypes() {
     return {
       link: PropTypes.shape({
@@ -57,30 +57,25 @@ export default class JaegerForceGraphArrowLink extends PureComponent {
   }
 
   render() {
-    const { link, targetRadius, edgeOffset, ...spreadable } = this.props;
+    const { link, targetRadius, edgeOffset: _, ...spreadable } = this.props;
     const id = `arrow-${linkId(link)}`;
     return (
       <g>
         <defs>
           <marker
             id={id}
-            markerWidth={(targetRadius * 3) + 1}
-            markerHeight={(targetRadius * 3) + 1}
-            refX={ targetRadius + link.target_node_size }
-            refY={targetRadius}
+            markerWidth={6}
+            markerHeight={4}
+            refX={5 + targetRadius}
+            refY={2}
             orient="auto"
             markerUnits="strokeWidth"
           >
-            {targetRadius > 0 && (
-              <path
-                d={`M0,0 L0,${targetRadius * 2} L${targetRadius * 3},${targetRadius} z`}
-                fill={spreadable.stroke || spreadable.color}
-              />
-            )}
+            {targetRadius > 0 && <path d="M0,0 L0,4 L6,2 z" fill={spreadable.stroke || spreadable.color} />}
           </marker>
         </defs>
 
-        <ForceGraphLink {...spreadable} link={link} edgeOffset={targetRadius} markerEnd={`url(#${id})`} />
+        <ForceGraphLink {...spreadable} link={link} markerEnd={`url(#${id})`} />
       </g>
     );
   }

Screen Shot 2019-05-14 at 3 44 25 PM

These changes

  • Uses the target node's radius instead of the default of 2
  • Use a static drawing of the arrow head and only adjust the refX to shift it based on the target node's radius
  • Omits the edgeOffset prop from the ForceGraphLink because that doesn't seem to do anything constructive

What do you think?

Apologies for the slow reply! Thank you for the diff!

@ghost ghost assigned tiffon May 16, 2019
@ghost ghost added the review label May 16, 2019
@Etienne-Carriere
Copy link
Contributor Author

@tiffon , I put the monkey_patch branch and then take in account your patch proposal. After you review, I propose to squash the commits before merge.

Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great!

I left a few comments, LMK if anything looks awry.

Also, it turns out the build failed due to the yarn prettier formatting task not being run on the changes. In the future, can you run yarn prettier before pushing?

@@ -0,0 +1,88 @@
// Copyright (c) 2017 Uber Technologies, Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of requests for this file.

Can you update the 2017 to 2019 in the copyright?

We're aiming to use TypeScript for all new files. Would you mind converting to *.tsx?

Also, I am thinking the Jaeger scoping of JaegerForceGraphArrowLink is kind of implied; what do you think of renaming to just ForceGraphArrowLink?

stroke: PropTypes.string,
strokeWidth: PropTypes.number
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we're using TypeScript, can you use a type instead of prop-types? E.g.

type TProps = {
  link: {
    source: string;
    target: string;
    value: string;
  };
  targetRadius: number;
  // etc
};

export default class JaegerForceGraphArrowLink extends PureComponent<TProps> {
  // ...

import { window } from 'global';
import { debounce } from 'lodash';
import {default as JaegerForceGraphArrowLink} from './JaegerForceGraphArrowLink';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The { default as ... } is not necessary; it can simply be:

import AnyName from './the-file';
// same as:
import { default as AnyName } from './the-file';

Ref

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

id={id}
markerWidth={6}
markerHeight={4}
refX={ 5 + link.target_node_size }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use targetRadius instead of link.target_node_size? The reason I figured using targetRadius is better is because link.target_node_size was not accurate. But, if your update fixes it, then we can get rid of targetRadius.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@Etienne-Carriere
Copy link
Contributor Author

@tiffon , I take in account all your comments but the conversion from JS to TypeScript . Sorry but I an not an JS dev only a "patcher"

@codecov
Copy link

codecov bot commented Jun 17, 2019

Codecov Report

Merging #373 into master will decrease coverage by 0.14%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   89.07%   88.93%   -0.15%     
==========================================
  Files         162      163       +1     
  Lines        3663     3670       +7     
  Branches      833      834       +1     
==========================================
+ Hits         3263     3264       +1     
- Misses        364      369       +5     
- Partials       36       37       +1
Impacted Files Coverage Δ
packages/jaeger-ui/src/propTypes/dependencies.js 100% <ø> (ø) ⬆️
packages/jaeger-ui/src/selectors/dependencies.js 100% <ø> (ø) ⬆️
...components/DependencyGraph/DependencyForceGraph.js 85% <100%> (+0.78%) ⬆️
.../components/DependencyGraph/ForceGraphArrowLink.js 33.33% <33.33%> (ø)
...eViewer/TimelineHeaderRow/TimelineViewingLayer.tsx 88.13% <0%> (-3.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f682682...0a19ebb. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 17, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@b8ca41d). Click here to learn what that means.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #373   +/-   ##
=========================================
  Coverage          ?   88.99%           
=========================================
  Files             ?      163           
  Lines             ?     3670           
  Branches          ?      834           
=========================================
  Hits              ?     3266           
  Misses            ?      367           
  Partials          ?       37
Impacted Files Coverage Δ
packages/jaeger-ui/src/propTypes/dependencies.js 100% <ø> (ø)
packages/jaeger-ui/src/selectors/dependencies.js 100% <ø> (ø)
...components/DependencyGraph/DependencyForceGraph.js 85% <100%> (ø)
.../components/DependencyGraph/ForceGraphArrowLink.js 33.33% <33.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8ca41d...4af19d4. Read the comment docs.

Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Etienne-Carriere Thanks for making the changes! No worries about the TypeScript, I went ahead and converted the new file.

Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write tests for the new component?

@yurishkuro
Copy link
Member

ping

@Etienne-Carriere
Copy link
Contributor Author

pong . Yes, I am late with writing the unit test . Will try this week

@Etienne-Carriere
Copy link
Contributor Author

The ts linter has some issues as it seems to be the first test in TypeScript. I will try to fix it.

@tiffon
Copy link
Member

tiffon commented Jul 10, 2019

Thanks for adding tests!

I think the CI failure is from adding types for jasmine and enzyme. These added types for node, which defines a Global type (apparently) and is in conflict with the const global defined in the custom typings.

We generally write tests in plain JavaScript, and it's preferable to be consistent.

Can you change the tests to be JS? Or, do you mind if I make the edit?

Etienne-Carriere and others added 6 commits July 12, 2019 10:57
Replace simple link by Arrow link in the Force Dependency graph so that the graph is more
understandable

Signed-off-by: Etienne Carriere <etienne.a.carriere@socgen.com>
Signed-off-by: Etienne Carriere <etienne.a.carriere@socgen.com>
Signed-off-by: Etienne Carriere <etienne.a.carriere@socgen.com>
Signed-off-by: Etienne Carriere <etienne.a.carriere@socgen.com>
Signed-off-by: Joe Farro <joef@uber.com>
Signed-off-by: Etienne Carriere <etienne.a.carriere@socgen.com>
@Etienne-Carriere
Copy link
Contributor Author

I put the test back in JS

@Etienne-Carriere
Copy link
Contributor Author

@tiffon , do you know why the codecov hook is hanged ?

@yurishkuro
Copy link
Member

I restarted the build

Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't. I restarted it over the weekend, too. It's not just this PR.

Thanks for contributing and making the changes!

@tiffon tiffon merged commit e197f15 into jaegertracing:master Jul 15, 2019
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 5, 2021
…egertracing#373)

Minor enhancement : Use Arrow Link for the Force Dependency graph
Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants